package com.yang.studentsapp.ui.campus;

import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.Matrix;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.text.Layout;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.yang.studentsapp.R;
import com.yang.studentsapp.ui.adapter.FragmentAdapter;

import java.util.ArrayList;
import java.util.IllegalFormatCodePointException;
import java.util.List;

/**
 * Created by ${Ян-Вэнь-Чао} on 2016/10/10.
 * 校园
 */
public class CampusFragment extends Fragment {
    private SimpleFragmentPagerAdapter pagerAdapter;

    private ViewPager viewPager;

    private TabLayout tabLayout;

    private SocietyFragment mSocietyfragment;
    private SchoolFragment mSchoolFragment;
    private List<Fragment> list_fragment;                                //定义要装fragment的列表
    private List<String> list_title;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_campus, container, false);
        viewPager = (ViewPager)view.findViewById(R.id.view_pager);
        tabLayout = (TabLayout) view.findViewById(R.id.tab_layout);
        initView();
        return view;
    }

    private void initView() {


        mSchoolFragment = new SchoolFragment();
        mSocietyfragment = new SocietyFragment();
        list_fragment = new ArrayList<Fragment>();
        list_fragment.add(mSchoolFragment);
        list_fragment.add(mSocietyfragment);

        list_title = new ArrayList<String>();
        list_title.add("学校");
        list_title.add("社会");

        tabLayout.addTab(tabLayout.newTab().setText(list_title.get(0)));
        tabLayout.addTab(tabLayout.newTab().setText(list_title.get(1)));
        pagerAdapter =
                new SimpleFragmentPagerAdapter(getActivity().getSupportFragmentManager(),
                list_fragment, list_title);
        viewPager.setAdapter(pagerAdapter);
        tabLayout.setupWithViewPager(viewPager);
        tabLayout.setTabMode(TabLayout.MODE_FIXED);

    }

}
